//////////////////////////////////////////////////////////////////////////////
//
//  Created by Philip Mulcahy on 05/02/2012.
//  Copyright (c) 2012 Philip Mulcahy. All rights reserved.
//
//  This file is part of the note-recog library.
//
//  note-recog is free software: you can redistribute it and/or modify
//  it under the terms of version 3 of the GNU Lesser General Public License 
//  as published by the Free Software Foundation.
//
//  note-recog is distributed is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with note-recog.  If not, see <http://www.gnu.org/licenses/>.
//
//////////////////////////////////////////////////////////////////////////////

#ifndef note_recog_Util_h
#define note_recog_Util_h

#include "Log.h"

class Util
{
private:
    LOG_DECLARE;
    
    static void logCheckFailure( long err, const char* msg );
    
public:
    template <typename T>
    static T check(T err);

    template <typename T>
    static T check(T err, const char* msg);
};

template <typename T>
T Util::check(T err)
{
    return check(err,"NULL");
}

template <typename T>
T Util::check(T err, const char* msg)
{
    if( err != 0 )
    {
        logCheckFailure( err, msg );
    }
    
    return err;
}  
#endif
